﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using PlatForm.DataLayer;

namespace PlatForm.Controller
{
    public class StockController
    {
        public List<Stock> GetALl(DateTime d)
        {
            var lstStock= Stock.Objects.Where(x=>x.StockDate==d.Date).ToList();
            var lstArticle = Article.Objects.ToList();
            var lstSupplier = Supplier.Objects.ToList();
            var lstOrder = Order.Objects.ToList();
            
            foreach (var s in lstStock)
            {
                var f = lstSupplier.FirstOrDefault(x => x.SUPPL_No == s.SUPPL_No);
                if (f != null)
                    s.SUPPL_Name = f.SUPPL_Name;
                var a = lstArticle.FirstOrDefault(x => x.ART_No == s.ART_No);
                if (a != null)
                    s.ART_Name = a.ART_Name;
                var o = lstOrder.FirstOrDefault(x => x.ORD_No == s.ORD_No);
                if (o != null)
                    s.ORD_QTY = o.DELI_QTY;
            }
            return lstStock;
        }

        public List<Stock> GetAll(string ORD_No)
        {
            return Stock.Objects.Where(x => x.ORD_No == ORD_No).ToList();
        }
    }
}
